﻿using System;
using CcrFlows.Core;
using Microsoft.Ccr.Core;

namespace SampleFlow
{
    class Program_SplitTextIntoWords
    {
        static void Main()
        {
            var flow = Flow<string>
                .Do<string>(SplitIntoWords)
                .Scatter<string>(ProcessWord);

            flow.Input.Post("the quick brown fox jumps over the lazy dog");

            flow.Receive(Console.WriteLine);

            Console.ReadLine();
        }

        static string ProcessWord(string word)
        {
            return word.ToUpper();
        }

        static void SplitIntoWords(string text, Port<string> words)
        {
            foreach (string word in text.Split(' '))
                words.Post(word);
        }
    }
}
